#include <iostream>
#include <string>
using namespace std;

const int N = 100;
const int MODEL = 11; 
string identies[N+1];
int a[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char M[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}; 
bool flag = true;
bool flagAll[N+1];
int m = 0;
bool isInt = true;

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> identies[i];
		if(identies[i].length() == 18){
			m = 0;  
			isInt = true;
			for(int j = 0; j < 17; j++){
				if(identies[i][j] >= '0' && identies[i][j] <= '9'){
					m += (identies[i][j] - '0')*a[j];
				}else{
					isInt = false;
					flag = false;
					break;
				}
			}
			if(isInt){
				m = m%MODEL;
				if(M[m] == identies[i][17]){
					flagAll[i] = true;
				}else flag = false;
			}
		}else flag = false;
	}

	if(flag) cout << "All passed";
	else{
		for(int i = 0; i < n; i++){	
			if(!flagAll[i]){
				cout << identies[i] << endl;
			}
		}
	}
	
	return 0;
}  
